import http from '@/utils/http'
import type { LabelValueState } from '@/types/global'

const BASE_URL = '/task/loc'

export interface LocResp {
  id: string
  name: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface LocDetailResp {
  id: string
  name: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface LocQuery {
  name: string
  createUser: string
  createTime: string
  sort: Array<string>
}
export interface LocPageQuery extends LocQuery, PageQuery {}

/** @desc 查询任务地点列表 */
export function listLoc(query: LocPageQuery) {
  return http.get<PageRes<LocResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询任务地点详情 */
export function getLoc(id: string) {
  return http.get<LocDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增任务地点 */
export function addLoc(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改任务地点 */
export function updateLoc(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除任务地点 */
export function deleteLoc(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出任务地点 */
export function exportLoc(query: LocQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}


/** @desc 查询任务地点列表 */
export function listLocDict(query?: { status: number }) {
  return http.get<LabelValueState[]>(`${BASE_URL}/dict`, query)
}
